import Router from "@koa/router";
import { WishController } from "../controllers/wish.controller";
import { AuthUtil } from "../utils/auth.util";
import { validateBody, validateParams } from "../middleware/validation";
import { idSchema } from "../validators/request.validator";
import { DishesIdListRequestSchema } from "../validators/dishes.validator";
import z from "zod";
import {
  createWishSchema,
  deleteWishSchema,
} from "../validators/wish.validator";

const wishRouter = new Router({
  prefix: "/api",
});

// 查询所有用户下周想吃的菜品列表
wishRouter.get("/wishes/statistics/next-week", WishController.listAllWishes);

// 查询用户下周想吃的菜品列表
wishRouter.get(
  "/users/:id/wishes",
  AuthUtil.isNormal(),
  validateParams(idSchema),
  WishController.listWishes
);

// 创建/修改用户（下周）想吃的菜品
wishRouter.put(
  "/users/:id/wishes",
  AuthUtil.isNormal(),
  validateParams(idSchema),
  validateBody(DishesIdListRequestSchema),
  WishController.upsertWishes
);

// 添加菜品到下周想吃
wishRouter.post(
  "/users/:id/wishes",
  AuthUtil.isNormal(),
  validateParams(idSchema),
  validateBody(createWishSchema),
  WishController.add
);

// 删除用户下周想吃的菜品
wishRouter.delete(
  "/users/:userId/wishes/:dishesId",
  AuthUtil.isNormal(),
  validateParams(deleteWishSchema),
  WishController.remove
);

export default wishRouter;
